import java.util.*;

public class Demo {
    public static void main(String[] args) {
        PriorityQueue<int[]> priorityQueue = new PriorityQueue<>(3,(a,b)->{
            return a[0]-b[0];
        });
        priorityQueue.offer(new int[]{1,1});
    }
}
class Solution {
    public List<Integer> topStudents(String[] positive_feedback, String[] negative_feedback, String[] report, int[] student_id, int k) {
        PriorityQueue<int[]> priorityQueue = new PriorityQueue<>((a1, a2) -> a1[1] == a2[1] ? a1[0] - a2[0] : a2[1] - a1[1]);
        Set<String> s1 = new HashSet<>();
        Set<String> s2 = new HashSet<>();
        for(String x : positive_feedback)
            s1.add(x);
        for(String x : negative_feedback)
            s2.add(x);
        for(int i=0; i<report.length; i++){
            String[] tmp = report[i].split(" ");
            int ans = 0;
            for(String x : tmp){
                if(s1.contains(x)) ans += 3;
                if(s2.contains(x)) ans -= 1;
            }
            priorityQueue.offer(new int[]{student_id[i],ans});
        }
        List<Integer> ret = new ArrayList<>();
        while(!priorityQueue.isEmpty()&&k>0){
            int[] x = priorityQueue.poll();
            ret.add(x[0]);
            k--;
        }
        return ret;
    }
}